package com.yq.leetcodeOld.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName Solution144
 * @Description preOrder
 * @Author yaoqiang
 * @Date 2022/3/22 14:12
 * @Version 1.0
 */
public class Solution144 {

    public List<Integer> preorderTraversal(TreeNode root){
        List<Integer> res=new ArrayList<>();
        preorder(root,res);
        return  res;
    }
    public void preorder(TreeNode root, List<Integer> res){
        if (root==null){return; }
        res.add(root.val);
        preorder(root.left,res);
        preorder(root.right,res);
    }
}
